Skip to content

Conversation

Abbas-Asad
Copy link
Contributor

Summary

Add a reusable type alias for agent instructions callbacks and use it in Agent.instructions to improve readability and consistency.

Changes Made

  • Added AgentInstructionsFunction in src/agents/agent.py:
    • AgentInstructionsFunction = Callable[[RunContextWrapper[TContext], "Agent[TContext]"], MaybeAwaitable[str]]
  • Updated Agent.instructions type to:
    • instructions: str | AgentInstructionsFunction | None = None
  • No behavioral changes; typing/clarity only.

### Summary
Add a reusable type alias for agent instructions callbacks and use it in `Agent.instructions` to improve readability and consistency.

### Changes Made
- Added `AgentInstructionsFunction` in `src/agents/agent.py`:
  - `AgentInstructionsFunction = Callable[[RunContextWrapper[TContext], "Agent[TContext]"], MaybeAwaitable[str]]`
- Updated `Agent.instructions` type to:
  - `instructions: str | AgentInstructionsFunction | None = None`
- No behavioral changes; typing/clarity only.


AgentInstructionsFunction: TypeAlias = Callable[
[RunContextWrapper[TContext], "Agent[TContext]"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to make this Agent[TContext] type be a string just for extracting the type here

@seratch
Copy link
Member

seratch commented Sep 22, 2025

Thanks for sending this patch but:

  • we don't want to make the Agent[TContext] type to be string just for extracting the type
  • the type is not reused at this moment, so I don't see the benefit of reusablity

For these reasons, let us close this.

@seratch seratch closed this Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants